﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="detailandmed_valismaa_ariyhing", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(DetailandmedValismaaAriyhing))]
    public class DetailandmedValismaaAriyhingSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IDetailandmedValismaaAriyhing clazz;
        
        public DetailandmedValismaaAriyhingSerializer(IDetailandmedValismaaAriyhing clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("arinimi");
            if (clazz.Arinimi!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_va_sisu", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.Arinimi.Count);
                for (int x = 0; ((clazz.Arinimi != null) 
                            && (x < clazz.Arinimi.Count)); x = (x + 1)) {
                    if (clazz.Arinimi[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaArinimi = this.GetMetaData(clazz.Arinimi[x]);
                        Writer.WriteTypeAttribute(metaArinimi.TypeQualifiedName.Namespace, metaArinimi.TypeQualifiedName.Name);
                        metaArinimi.NewSerializer(clazz.Arinimi[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Arinimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("asukoht");
            if (clazz.Asukoht!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_va_asukoht", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.Asukoht.Count);
                for (int x = 0; ((clazz.Asukoht != null) 
                            && (x < clazz.Asukoht.Count)); x = (x + 1)) {
                    if (clazz.Asukoht[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaAsukoht = this.GetMetaData(clazz.Asukoht[x]);
                        Writer.WriteTypeAttribute(metaAsukoht.TypeQualifiedName.Namespace, metaAsukoht.TypeQualifiedName.Name);
                        metaAsukoht.NewSerializer(clazz.Asukoht[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Asukoht");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("sarnane_eesti_oiguslik_vorm");
            if (clazz.SarnaneEestiOiguslikVorm!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_va_sisu", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.SarnaneEestiOiguslikVorm.Count);
                for (int x = 0; ((clazz.SarnaneEestiOiguslikVorm != null) 
                            && (x < clazz.SarnaneEestiOiguslikVorm.Count)); x = (x + 1)) {
                    if (clazz.SarnaneEestiOiguslikVorm[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaSarnaneEestiOiguslikVorm = this.GetMetaData(clazz.SarnaneEestiOiguslikVorm[x]);
                        Writer.WriteTypeAttribute(metaSarnaneEestiOiguslikVorm.TypeQualifiedName.Namespace, metaSarnaneEestiOiguslikVorm.TypeQualifiedName.Name);
                        metaSarnaneEestiOiguslikVorm.NewSerializer(clazz.SarnaneEestiOiguslikVorm[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SarnaneEestiOiguslikVorm");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("sarnane_eesti_oiguslik_vorm_markus");
            if (clazz.SarnaneEestiOiguslikVormMarkus!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_va_sisu", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.SarnaneEestiOiguslikVormMarkus.Count);
                for (int x = 0; ((clazz.SarnaneEestiOiguslikVormMarkus != null) 
                            && (x < clazz.SarnaneEestiOiguslikVormMarkus.Count)); x = (x + 1)) {
                    if (clazz.SarnaneEestiOiguslikVormMarkus[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaSarnaneEestiOiguslikVormMarkus = this.GetMetaData(clazz.SarnaneEestiOiguslikVormMarkus[x]);
                        Writer.WriteTypeAttribute(metaSarnaneEestiOiguslikVormMarkus.TypeQualifiedName.Namespace, metaSarnaneEestiOiguslikVormMarkus.TypeQualifiedName.Name);
                        metaSarnaneEestiOiguslikVormMarkus.NewSerializer(clazz.SarnaneEestiOiguslikVormMarkus[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SarnaneEestiOiguslikVormMarkus");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("maa_mille_seaduse_alusel_tegutseb");
            if (clazz.MaaMilleSeaduseAluselTegutseb!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_va_sisu", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.MaaMilleSeaduseAluselTegutseb.Count);
                for (int x = 0; ((clazz.MaaMilleSeaduseAluselTegutseb != null) 
                            && (x < clazz.MaaMilleSeaduseAluselTegutseb.Count)); x = (x + 1)) {
                    if (clazz.MaaMilleSeaduseAluselTegutseb[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaMaaMilleSeaduseAluselTegutseb = this.GetMetaData(clazz.MaaMilleSeaduseAluselTegutseb[x]);
                        Writer.WriteTypeAttribute(metaMaaMilleSeaduseAluselTegutseb.TypeQualifiedName.Namespace, metaMaaMilleSeaduseAluselTegutseb.TypeQualifiedName.Name);
                        metaMaaMilleSeaduseAluselTegutseb.NewSerializer(clazz.MaaMilleSeaduseAluselTegutseb[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : MaaMilleSeaduseAluselTegutseb");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("maa_mille_seaduse_alusel_tegutseb_markus");
            if (clazz.MaaMilleSeaduseAluselTegutsebMarkus!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_va_sisu", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.MaaMilleSeaduseAluselTegutsebMarkus.Count);
                for (int x = 0; ((clazz.MaaMilleSeaduseAluselTegutsebMarkus != null) 
                            && (x < clazz.MaaMilleSeaduseAluselTegutsebMarkus.Count)); x = (x + 1)) {
                    if (clazz.MaaMilleSeaduseAluselTegutsebMarkus[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaMaaMilleSeaduseAluselTegutsebMarkus = this.GetMetaData(clazz.MaaMilleSeaduseAluselTegutsebMarkus[x]);
                        Writer.WriteTypeAttribute(metaMaaMilleSeaduseAluselTegutsebMarkus.TypeQualifiedName.Namespace, metaMaaMilleSeaduseAluselTegutsebMarkus.TypeQualifiedName.Name);
                        metaMaaMilleSeaduseAluselTegutsebMarkus.NewSerializer(clazz.MaaMilleSeaduseAluselTegutsebMarkus[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : MaaMilleSeaduseAluselTegutsebMarkus");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("register");
            if (clazz.Register!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_va_sisu", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.Register.Count);
                for (int x = 0; ((clazz.Register != null) 
                            && (x < clazz.Register.Count)); x = (x + 1)) {
                    if (clazz.Register[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaRegister = this.GetMetaData(clazz.Register[x]);
                        Writer.WriteTypeAttribute(metaRegister.TypeQualifiedName.Namespace, metaRegister.TypeQualifiedName.Name);
                        metaRegister.NewSerializer(clazz.Register[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Register");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("registreerimisnumber");
            if (clazz.Registreerimisnumber!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_va_sisu", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.Registreerimisnumber.Count);
                for (int x = 0; ((clazz.Registreerimisnumber != null) 
                            && (x < clazz.Registreerimisnumber.Count)); x = (x + 1)) {
                    if (clazz.Registreerimisnumber[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaRegistreerimisnumber = this.GetMetaData(clazz.Registreerimisnumber[x]);
                        Writer.WriteTypeAttribute(metaRegistreerimisnumber.TypeQualifiedName.Namespace, metaRegistreerimisnumber.TypeQualifiedName.Name);
                        metaRegistreerimisnumber.NewSerializer(clazz.Registreerimisnumber[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Registreerimisnumber");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("majandusaasta_aruande_avalikustamise_kohustus");
            if (clazz.MajandusaastaAruandeAvalikustamiseKohustus!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_va_sisu", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.MajandusaastaAruandeAvalikustamiseKohustus.Count);
                for (int x = 0; ((clazz.MajandusaastaAruandeAvalikustamiseKohustus != null) 
                            && (x < clazz.MajandusaastaAruandeAvalikustamiseKohustus.Count)); x = (x + 1)) {
                    if (clazz.MajandusaastaAruandeAvalikustamiseKohustus[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaMajandusaastaAruandeAvalikustamiseKohustus = this.GetMetaData(clazz.MajandusaastaAruandeAvalikustamiseKohustus[x]);
                        Writer.WriteTypeAttribute(metaMajandusaastaAruandeAvalikustamiseKohustus.TypeQualifiedName.Namespace, metaMajandusaastaAruandeAvalikustamiseKohustus.TypeQualifiedName.Name);
                        metaMajandusaastaAruandeAvalikustamiseKohustus.NewSerializer(clazz.MajandusaastaAruandeAvalikustamiseKohustus[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : MajandusaastaAruandeAvalikustamiseKohustus");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="arinimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_valismaa_ariyhing>arinimi");
                }
                clazz.Arinimi = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("arinimi");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_va_sisud>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaArinimi = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu>(Reader, "detailandmed_va_sisu", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu item = metaArinimi.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu>();
                        clazz.Arinimi.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaArinimi.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmed_valismaa_ariyhing>arinimi", Reader.LocalName);
            }
            if (Reader.LocalName=="asukoht") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_valismaa_ariyhing>asukoht");
                }
                clazz.Asukoht = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaAsukoht>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("asukoht");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_va_asukohad>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaAsukoht = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaAsukoht>(Reader, "detailandmed_va_asukoht", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaAsukoht item = metaAsukoht.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaAsukoht>();
                        clazz.Asukoht.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaAsukoht.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmed_valismaa_ariyhing>asukoht", Reader.LocalName);
            }
            if (Reader.LocalName=="sarnane_eesti_oiguslik_vorm") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_valismaa_ariyhing>sarnane_eesti_oiguslik_vorm");
                }
                clazz.SarnaneEestiOiguslikVorm = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("sarnane_eesti_oiguslik_vorm");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_va_sisud>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaSarnaneEestiOiguslikVorm = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu>(Reader, "detailandmed_va_sisu", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu item = metaSarnaneEestiOiguslikVorm.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu>();
                        clazz.SarnaneEestiOiguslikVorm.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaSarnaneEestiOiguslikVorm.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmed_valismaa_ariyhing>sarnane_eesti_oiguslik_vorm", Reader.LocalName);
            }
            if (Reader.LocalName=="sarnane_eesti_oiguslik_vorm_markus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_valismaa_ariyhing>sarnane_eesti_oiguslik_vorm_markus");
                }
                clazz.SarnaneEestiOiguslikVormMarkus = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("sarnane_eesti_oiguslik_vorm_markus");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_va_sisud>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaSarnaneEestiOiguslikVormMarkus = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu>(Reader, "detailandmed_va_sisu", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu item = metaSarnaneEestiOiguslikVormMarkus.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu>();
                        clazz.SarnaneEestiOiguslikVormMarkus.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaSarnaneEestiOiguslikVormMarkus.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmed_valismaa_ariyhing>sarnane_eesti_oiguslik_vorm_markus", Reader.LocalName);
            }
            if (Reader.LocalName=="maa_mille_seaduse_alusel_tegutseb") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_valismaa_ariyhing>maa_mille_seaduse_alusel_tegutseb");
                }
                clazz.MaaMilleSeaduseAluselTegutseb = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("maa_mille_seaduse_alusel_tegutseb");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_va_sisud>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaMaaMilleSeaduseAluselTegutseb = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu>(Reader, "detailandmed_va_sisu", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu item = metaMaaMilleSeaduseAluselTegutseb.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu>();
                        clazz.MaaMilleSeaduseAluselTegutseb.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaMaaMilleSeaduseAluselTegutseb.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmed_valismaa_ariyhing>maa_mille_seaduse_alusel_tegutseb", Reader.LocalName);
            }
            if (Reader.LocalName=="maa_mille_seaduse_alusel_tegutseb_markus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_valismaa_ariyhing>maa_mille_seaduse_alusel_tegutseb_markus");
                }
                clazz.MaaMilleSeaduseAluselTegutsebMarkus = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("maa_mille_seaduse_alusel_tegutseb_markus");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_va_sisud>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaMaaMilleSeaduseAluselTegutsebMarkus = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu>(Reader, "detailandmed_va_sisu", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu item = metaMaaMilleSeaduseAluselTegutsebMarkus.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu>();
                        clazz.MaaMilleSeaduseAluselTegutsebMarkus.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaMaaMilleSeaduseAluselTegutsebMarkus.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmed_valismaa_ariyhing>maa_mille_seaduse_alusel_tegutseb_markus", Reader.LocalName);
            }
            if (Reader.LocalName=="register") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_valismaa_ariyhing>register");
                }
                clazz.Register = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("register");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_va_sisud>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaRegister = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu>(Reader, "detailandmed_va_sisu", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu item = metaRegister.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu>();
                        clazz.Register.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaRegister.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmed_valismaa_ariyhing>register", Reader.LocalName);
            }
            if (Reader.LocalName=="registreerimisnumber") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_valismaa_ariyhing>registreerimisnumber");
                }
                clazz.Registreerimisnumber = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("registreerimisnumber");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_va_sisud>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaRegistreerimisnumber = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu>(Reader, "detailandmed_va_sisu", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu item = metaRegistreerimisnumber.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu>();
                        clazz.Registreerimisnumber.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaRegistreerimisnumber.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmed_valismaa_ariyhing>registreerimisnumber", Reader.LocalName);
            }
            if (Reader.LocalName=="majandusaasta_aruande_avalikustamise_kohustus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_valismaa_ariyhing>majandusaasta_aruande_avalikustamise_kohustus");
                }
                clazz.MajandusaastaAruandeAvalikustamiseKohustus = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("majandusaasta_aruande_avalikustamise_kohustus");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_va_sisud>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaMajandusaastaAruandeAvalikustamiseKohustus = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu>(Reader, "detailandmed_va_sisu", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu item = metaMajandusaastaAruandeAvalikustamiseKohustus.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedVaSisu>();
                        clazz.MajandusaastaAruandeAvalikustamiseKohustus.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaMajandusaastaAruandeAvalikustamiseKohustus.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmed_valismaa_ariyhing>majandusaasta_aruande_avalikustamise_kohustus", Reader.LocalName);
            }
        }
    }
}
